<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	//http://localhost:8080/logistics/
%>
<html>
<head>
<!-- 设置页面的 基本路径，页面所有资源引入和页面的跳转全部基于 base路径 -->
<base href="<%=basePath%>">
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="lib/zTree/v3/css/zTreeStyle/zTreeStyle.css" type="text/css">

<script type="text/javascript" src="lib/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript" src="lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>

<script type="text/javascript">
	/* zTree的设置对象 */
	var setting = {
		data : {
			/* 支持简单json格式数据 */
			simpleData : {
				enable : true,
				/* zTree数据的id名称 */
				idKey: "permissionId",
				/* zTree数据的父id名称 */
				pIdKey: "parentId",
			}
		},
		/* 是否支持复选框 */
		check : {
			enable : true
		},
		/* 异步加载数据 */
		async : {
			enable : true,
			url : "permission/getAllPermission.do",
			/* 对加载的数据进行预处理 */
			dataFilter: ajaxDataFilter
		}
	};
	
	/* 数据预处理函数 */
	function ajaxDataFilter(treeId, parentNode, responseData) {
   
		if (responseData) {
			for (var i = 0; i < responseData.length; i++) {
					/* 为每一行节点数据添加一个open属性，让其节点展开 */	
					responseData[i].open =true;
				}
		}
		return responseData;
	};
	
	$(function() {
		//初始化zTree
		$.fn.zTree.init($("#permissionTree"), setting);
	});
</script>


</head>
<body>


	<ul id="permissionTree" class="ztree"></ul>

</body>
</html>